package video

import (
	"fmt"
	"os"
	"os/exec"
	// Terminal UI
	"github.com/pterm/pterm"
)

func PlayVideo(hrefVideo string) {
	// Select play/download
	var videoApp string
	videoApps := []string {"Play", "Download"}
	videoMethod, _ := pterm.DefaultInteractiveSelect.WithOptions(videoApps).Show()
	if videoMethod == "Play" { videoApp = "mpv"}
	if videoMethod == "Download" {videoApp = "youtube-dl"}

	fmt.Println(videoMethod, "video")
	fmt.Println("Please wait...")
	fmt.Println(videoApp, hrefVideo)

	cmd := exec.Command(videoApp, hrefVideo)
	err := cmd.Run()
	if err != nil {
			fmt.Println("Please check you internet connection and mpv+youtube-dl on youre computer")
			os.Exit(1)
	}
}

